﻿using System.Configuration;
using YawetagDemo.Framework.Impl.Data;
using YawetagDemo.Framework.Server.Services;
using YawetagLib.System.Data;
using YawetagLib.System.Data.L2Sql;

namespace YawetagDemo.Framework.Server.Console.Core
{
    class Program
    {
        static void Main()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["default-connection-string"].ConnectionString;

            DataContextBuilder.RegisterDataContexts(DataContextInfo.New(
                typeof(DbModelDataContext), i => new DataContextAdapter(new DbModelDataContext(connectionString))));

            WCFServiceHost serviceHost = new WCFServiceHost();
            serviceHost.Closed += (o, e) => System.Console.WriteLine("[...] ServiceHost closed");

            serviceHost.Open();

            System.Console.WriteLine("[...] ServiceHost available, press <ENTER> to exit");
            System.Console.WriteLine();
            System.Console.ReadLine();

            serviceHost.Close();
        }
    }
}
